<!-- 企业查看求职者简历 -->
<template>
	<view class="main">
		<u-navbar
			title="个人简历"
			@leftClick="navigateBack"
			safeAreaInsetTop
			fixed
			placeholder
			:autoBack="true"
		></u-navbar>
		<view class="main_head">
			<view class="main_details_box">
				<view class="item-avatar">
					<image :src="imgURL+info.avatar" ></image>
				</view>	
				<view class="item-box">
					<view class="item-info">
						<text class="item-name" v-if="info.name">姓名：{{info.name || ''}}</text>
						<view class="item-auth"><image src="../../static/img/auth.png" ></image></view>
					</view>
					<view class="item-info">
						<text>{{info.huji || ''}} · {{info.sex || ''}} · {{info.age1 ||''}} · {{info.is_hun ||''}}</text>
					</view>
					<view class="item-phone" v-if="info.phone"> 
						联系电话：	{{info.phone || ""}}
					</view>
					<view class="item-job" v-if="info.job_status">
							在职状态：{{info.job_status || ""}}
					</view>
					<view class="item-map" v-if="info.school">
						毕业学院：{{info.school || ""}}
					</view>
				</view>
			</view>
			<view class="item-skill">
				<image src="../../static/img/map-lan.png" ></image>
				{{info.address || ""}}
			</view>
		</view>
		<view class="main_details_content">
			<view class="main_details_content_box">
				<view class="main_details_title" style="margin-bottom: 20rpx;display: flex; justify-content: space-between;align-items: center;">
					<view>求职意向</view> 
				</view>
				<view class="main_details_box css3order" style="width: 600rpx;">
					<view class="main_details_box_job" style="margin: 0;">
						<view class="main_details_box_job_time">
							工作经验：{{info.work_y ? info.work_y :''}}  -  {{info.education ? info.education :''}}
						</view>
					<view class="main_details_box_job_time" v-if="info.skill">
						技能：{{info.skill || ""}}
					</view>
						<view class="main_details_box_job_time">
							期望城市：{{info.expect_city ? info.expect_city :''}}
						</view>
						<view class="main_details_box_job_time">
							期望薪资：{{info.salary ? info.salary :''}}
						</view>
						<view class="main_details_box_job_intro">
							人生规划：{{info.plan ? info.plan :''}}
						</view>
					</view>
				</view>
			</view>
			<view class="main_details_content_box" style="margin-top:60rpx">
				<view class="main_details_title" style="display: flex; justify-content: space-between;align-items: center;">
				<view>视频展示</view>
				</view>
				<view class="main_details_box" v-if="info.is_open_video == 1">
					<view class="main_details_box_job">
						<view v-if="info.video_url">
							<video style="width: 560rpx;height: 300rpx;" :src="imgURL+info.video_url"></video>
							<!-- <video-player :title="'个人视频简历'" :videoSrc="imgURL+info.video_url" :videoType="'mp4'">
							 </video-player> -->
						</view>
						<view class="main_details_box_job_intro">
							{{info.intro}}
						</view>
					</view>
				</view>
			</view>
			<view class="main_details_content_box" style="margin-top:60rpx">
				<view class="main_details_title" style="display: flex; justify-content: space-between;align-items: center;">
				<view>作品集</view>
				</view>
				<view class="main_details_box" v-if="imgs.length > 0">
					<view class="main_details_box_job">
						<block v-for="(item,index) in imgs" :key="index">
							<image @click="shoImg(index)" style="width: 170rpx;height: 170rpx;margin-left: 20rpx;margin-bottom: 20rpx;" :src="imgURL+item"></image>
						</block>
					</view>
				</view>
			</view>
		</view>
		<view class="main_details_content" style="padding-bottom: 140rpx;">
			<view class="main_details_content_box">
					<view class="main_details_title" style="display: flex; justify-content: space-between;align-items: center;">
						<view>工作经验</view> 
					</view>
					<block v-for="(item,index) in info.explist">
						<view class="main_details_box">
							<view class="main_details_box_job_left">
								<image style="width:50rpx;height:50rpx" src="../../static/img/dian1.png"></image> 
							</view>
								
							<view class="main_details_box_job">
								<view class="main_details_box_job_company">
									<view>在职时间：{{item.startDate || ""}}-{{item.endDate || ""}}</view>
								</view>
								<view class="css3order" style="width: 520rpx;">
									<view class="main_details_box_job_time" style="color: #333333;font-size: 30rpx;font-weight: bold;">
										公司：{{item.companyName || ""}} 
									</view>
									<view class="main_details_box_job_time">
										岗位：{{item.positionName || ""}}</view>
									<view class="main_details_box_job_intro">
										负责：{{item.workContent || ""}}
									</view>
								</view>
							</view>
						</view>
					</block>
				</view>
			</view>
			<view class="main_resume_foot" v-if="source">
				<view class="foot_right" @click="openmodel">邀请</view>
			</view>
			
			<u-modal
				title="邀请面试"
				:show="yaoqingModal"
				showCancelButton
				asyncClose
				@confirm="yaoqingconfirm"
				@cancel="() => yaoqingModal = false"
			>
				<u--form
					labelPosition="left"
					:model="form"
					ref="form"
				>
					<u-form-item
						label="邀请职位"
						prop="education"
						borderBottom
						labelWidth="80"
						@click="showPicker(index)"
					>
						<u--input
							v-model="yaoqingform.position_name"
							border="none"
							disabled
							placeholder="职位名称"
						></u--input>
						<u-icon
							slot="right"
							name="arrow-right"
						></u-icon>
					</u-form-item>
					<u-form-item
						label="面试时间"
						prop="interview_time"
						labelWidth="80"
						@click="showDatetimePicker"
					>
						<u--input
							v-model="yaoqingform.interview_date"
							border="none"
							disabled
							placeholder="面试时间"
						></u--input>
					</u-form-item>
				</u--form>
			</u-modal>
			<u-datetime-picker
				:show="timeshow"
				v-model="form.interview_date"
				mode="datetime"
				closeOnClickOverlay
				@confirm="timeconfirm"
				@cancel="timecancel"
				@close="timeclose"
			></u-datetime-picker>
			<u-picker
				:show="showposition"
				:columns="positionList"
				keyName="position"
				@cancel="positioncancel"
				@confirm="positionconfirm"
			></u-picker>
	</view>
</template>

<script>
	import util from "@/utils/utils.js"
	import videoPlayer from '@/components/video'
	import { getUserResume } from '@/api/resume.js'
	import { getMyPosition } from '@/api/position.js'
		import { AjaxInvi  } from '@/api/enterprise.js'
	import { imgURL } from '@/utils/config'
	export default {
		components: {
			videoPlayer
		},
		data() {
			return {
				source:true,
				yaoqingModal:false,
				showposition:false,
				timeshow:false,
				money:0,
				imgURL:imgURL,
				id:'',
				info: '',
				height:0,
				showModal:false,
				imgs:[],
				form:{
					companyName:'',//公司名称
					department:'',//所属部门
					positionName:'',//职位名称
					startDate:'',//入职时间
					endDate:'',//离职职时间
					workContent:'',//项目内容
				},
				yaoqingform:{
					uid:'',
					position_id:'',
					position_name:'',
					interview_time:'',
					interview_date:''
				},
				positionList:[],
				defaultIndex:[[]]
			}
		},
		onLoad(option) {
			const that = this
			if(!option.id){
				uni.navigateBack()
			}
			if(option.source){
				this.source = false
			}
			this.id = option.id
			this.money = option.money
			uni.getSystemInfo({
				success: (res)=> {
					that.height = res.windowHeight- uni.upx2px(100)-260 //获取系统信息，可使用窗口的高度
				}
			});
			this.getResume()
		},
		methods: {
			//获取信息
			getResume() {
				getUserResume({uid:this.id}).then(res=>{
					if(res.code == 200){
						this.info = res.data
						if(res.data.imgs){
							this.imgs = JSON.parse(res.data.imgs)
						}
					}
					else{
						return uni.showToast({
							title:res.msg,
							duration: 2000,
							icon:'none',
							success() {
								uni.navigateBack()
							}
						});
				}
					
				})
			},
			
			//邀请弹窗
			openmodel() {
				// if(this.money < 5){
				// 	return uni.showToast({
				// 		icon: 'none',
				// 		title: "猫币不足请充值"
				// 	});
				// }
				this.yaoqingform.uid = this.info.uid
				this.yaoqingModal = true
				this.positionList = []
				getMyPosition().then(res=>{
					this.positionList.push(res.data)
					this.yaoqingform.interview_time = Math.round(new Date().getTime()/1000).toString()
					this.yaoqingform.interview_date = formatTime(this.yaoqingform.interview_time,'Y-M-D h:m')
				})
			},
			
			//提交邀请
			yaoqingconfirm(){
				let that = this
				if (this.yaoqingform.position_id == "") {
					return uni.showToast({
						icon: 'none',
						title: '请选择邀请岗位'
					});
				}
				if (this.yaoqingform.interview_time == "") {
					return uni.showToast({
						icon: 'none',
						title: '请选择面试时间'
					});
				}
				AjaxInvi(this.yaoqingform).then(res=>{
					that.yaoqingModal = false
					if(res.code == 200){
						uni.showToast({
							title:res.msg,
							duration: 2000,
							icon:'none',
							success() {
								
							}
						});
					}
					else{
						return uni.showToast({
							title:res.msg,
							duration: 2000,
							icon:'none'
						});
					}
				})
			},
			
			//选择职位
			PickerChange(e){
				let index = e.detail.value
				this.form.fieldname = this.catelist[index].job_cate_name
				this.form.field = this.catelist[index].job_cate_id
			},
			//showPicker
			showPicker(){
				this.showposition = true
			},
			positionclose() {
				this.showposition = false
			},
			positionconfirm(e) {
				this.showposition = false
				this.yaoqingform.position_name = e.value[0].position
				this.yaoqingform.position_id = e.value[0].position_id
			},
			positioncancel() {
				this.showposition = false
			},
			//时间弹窗关闭
			timeclose() {
				this.timeshow = false
			},
			//开启时间弹窗
			showDatetimePicker() {
				this.timeshow = true
			},
			timecancel() {
				this.timeshow = false
			},
			timeconfirm(e) {
				this.timeshow = false
				this.yaoqingform.interview_time = e.value/1000
				const timeFormat = uni.$u.timeFormat
				this.yaoqingform.interview_date = timeFormat(e.value, 'yyyy-mm-dd hh:MM')
			
			},
			
			shoImg(index){
				var imgbox = [];
				for(let i in this.imgs){
					imgbox.push(this.imgURL+this.imgs[i])
				}
				uni.previewImage({
					//当前显示图片
					current: imgbox[index],
					//所有图片
					urls: imgbox
				})
			},
			
			goto(tourl) {
				uni.navigateTo({
					url: tourl
				});
			}
		},
	}
	
</script>

<style lang="scss">
	@import "../../static/css/resumedetails.scss";
</style>